<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
Date now=new Date();
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>匿名测试</title>
    <link href="css/qt/nmks.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="script/jquery/jquery-1.5.1.min.js">
        </script>
    <script type="text/javascript">
        <c:if test="${!empty queslist}">
          <c:if test="${!empty queslist.xzlist}">
          var xzids=new Array(<c:forEach items="${queslist.xzlist }" var="ques" varStatus="ss">${ques.id},</c:forEach>0);
	     </c:if>
         <c:if test="${!empty queslist.tklist}">
         var tkids=new Array(<c:forEach items="${queslist.tklist }" var="ques" varStatus="ss">${ques.id},</c:forEach>0);
	     </c:if>
	     <c:if test="${!empty queslist.pdlist}">
         var pdids=new Array(<c:forEach items="${queslist.pdlist }" var="ques" varStatus="ss">${ques.id},</c:forEach>0);
	     </c:if>
        </c:if>
        var xzans="${xzds}";
        var tkans="${tkds}";
        var pdans="${pdds}";
        function initUserAns(){
        	if(xzans.length>0){
        		var xzana=xzans.split("#");
        		if(xzana.length>0){
        			for(var i=0;i<xzana.length;i++){
        				if(xzana[i].indexOf("|")>-1){
        					for(var j=0;j<xzana[i].split(":")[1].split("|").length;j++){
        						$("input[name='"+xzana[i].split(":")[0]+"']").each(function(){
        						 if($(this).val()==xzana[i].split(":")[1].split("|")[j])
			                      $(this).attr("checked",true);
			           	    	});
        					}
        				}else{
        					 $("input[name='"+xzana[i].split(":")[0]+"']").each(function(){
        						 if($(this).val()==xzana[i].split(":")[1])
			                      $(this).attr("checked",true);
			           	    	});
        				}
        			}
        		}
        	}
        	if(tkans.length>0){
        		var tkana=tkans.split("#");
        		if(tkana.length>0){
        			for(var i=0;i<tkana.length;i++){
        				if(tkana[i].indexOf("|")>-1){
        					for(var j=0;j<tkana[i].split(":")[1].split("|").length;j++){
        						$("input[name='"+tkana[i].split(":")[0]+"']").eq(j).val(tkana[i].split(":")[1].split("|")[j]);
        					}
        				}else{
        					 $("input[name='"+tkana[i].split(":")[0]+"']").eq(0).val(tkana[i].split(":")[1]);
        				}
        			}
        		}
        	}
        	if(pdans.length>0){
        		var pdana=pdans.split("#");
        		if(pdana.length>0){
       			    for(var i=0;i<pdana.length;i++){
      					 $("input[name='"+pdana[i].split(":")[0]+"']").each(function(){
      						 if($(this).val()==pdana[i].split(":")[1])
	                      $(this).attr("checked",true);
	           	    	});
       				}
       			}
        	}
        }
	    $(function() {
	        if(!window.ActiveXObject){
	            $("#footht").css("height","20px");
	        }
	         initZYbg();
	        <c:if test="${!empty score}">
	          initUserAns();
	        </c:if>
	   	   	$(window).resize(function() {
			    initZYbg();
			   });
	    });
function initZYbg(){ 
	//alert($(document).width());
       if(document.body.clientWidth<957){
	        $("#mainleft").width(0);
	        $("#mainright").width(0);
	        $("#mainleft").css("display","none");
		    $("#mainright").css("display","none");
        }else{
	       if(!window.ActiveXObject){
		        var wid=($(document).width()-953)/2;
		        $("#mainleft").width(wid);
		        $("#mainright").width(wid);
		        $("#mainleft").css("display","block");
		        $("#mainright").css("display","block");
		    }else{
		        var wid=($(document).width()-974)/2;
		        if(wid>0){
		        	$("#mainleft").width(wid);
			        $("#mainright").width(wid);
			        $("#mainleft").css("display","block");
			        $("#mainright").css("display","block");
		        }
		    }
        }
}
	    
	    function JiaoJuan(){
		    var xzans="",tkans="",pdans="";
	    	var temp="";
               for(var i=0;i<xzids.length-1;i++){
            	   $("input[name='"+xzids[i]+"']").each(function(){
                      if($(this).attr("checked"))
                    	temp=temp+$(this).val()+"|";
           	    	});
          	    	if(temp.length>0){
          	    		xzans=xzans+xzids[i]+":"+temp.substring(0,temp.length-1)+"#";
          	    		temp="";
          	    	} 
               }
               for(var i=0;i<tkids.length-1;i++){
            	   $("input[name='"+tkids[i]+"']").each(function(){
                      if($(this).val().length>0){
                    	temp=temp+$(this).val()+"|";
                      }else{
                    	  temp=temp+" |";
                          }
           	    	});
          	    	if(temp.length>0){
          	    		tkans=tkans+tkids[i]+":"+temp.substring(0,temp.length-1)+"#";
          	    		temp="";
          	    	} 
               }
               for(var i=0;i<pdids.length-1;i++){
            	   $("input[name='"+pdids[i]+"']").each(function(){
                      if($(this).attr("checked"))
                    	temp=temp+$(this).val()+"|";
           	    	});
          	    	if(temp.length>0){
          	    		pdans=pdans+pdids[i]+":"+temp.substring(0,temp.length-1)+"#";
          	    		temp="";
          	    	} 
               }
               if(xzans.length>0){
            	  xzans=xzans.substring(0,xzans.length-1);
               }
              if(tkans.length>0){
            	  tkans=tkans.substring(0,tkans.length-1);
               }
               if(pdans.length>0){
            	  pdans=pdans.substring(0,pdans.length-1);
               }
               $("#xzds").attr("value",xzans);
               $("#tkds").attr("value",tkans);
               $("#pdds").attr("value",pdans);  
               $("#jiaojuansum").submit();
	    }
    </script>
    <SCRIPT LANGUAGE="JavaScript">   
		<!--   
		var maxtime = 1799;//60*30 //一个小时，按秒计算，自己调整!   
		function CountDown(){   
		if(maxtime>=0){   
			minutes = Math.floor(maxtime/60);   
			seconds = Math.floor(maxtime%60);   
			msg = minutes+":"+seconds;   
			document.all["timer"].innerHTML=msg;   
			//if(maxtime == 5*60) alert('注意，还有5分钟!');   
			--maxtime;   
		}else{   
			clearInterval(timer);   
			JiaoJuan();
			alert("时间到，考试结束!"); 
			}   
		}   
		 <c:if test="${!empty queslist}">
		  timer = setInterval("CountDown()",1000);   
	     </c:if>
		
		//-->   
</SCRIPT>   
  </head>
  
  <body>
    <div id="mainleft"><img src="img/qt/mainleft.jpg" style="width:100%;height:100%;"/></div>
     <div id="main">
      <div id="top">
            <jsp:include page="nmkstitle.jsp" flush="true">
             <jsp:param name="jspName" value="mykh" />
           </jsp:include>
           <div class="clear"></div>
       </div>
       <div id="tgTXT">
           <div id="tiao" style=""></div>
           <div id="mainbg">
	           <div style="height:10px;"> </div>
	           <div id="nowlist">
	              <div style="font-weight: bolder;margin-top:10px;"><%=now.getYear()+1900%>年舟山市电力公司信息化技术比武</div>
	              <c:if test="${empty score}">
	              <div id="timeleng" style="width:100px;font-size:12px;float:left;margin:10px 0 0 400px;">[&nbsp;30分钟&nbsp;]</div>
	              <div id="timer" style="width:100px;font-size:12px;margin:10px 0 0 300px;float:left;font-weight: bolder;color:#FF9B35">30:00</div>
	              </c:if>
	              <c:if test="${!empty score}">
	              <div style="font-size:13px; margin-top:10px;"><span>您于<%=now.getMonth()+1%>月<%=now.getDay()%>日<%=now.getHours()%>:<%=now.getMinutes()%>分完成了本次测试&nbsp;&nbsp;</span> <span style="color:#F9943E;font-size:15px;">成绩：${score }分</span></div>
	              </c:if>
	           </div>
	           <div style="height:20px;clear:both;"> </div>
	           <c:if test="${!empty queslist}">
	              <table id="titable" cellpadding="0" cellspacing="0">
				    <tr><td style="height:25px;" colspan="2">一、选择题（20*2分）</td></tr>
				     <c:if test="${!empty queslist.xzlist}">
				       <c:forEach items="${queslist.xzlist }" var="ques" varStatus="ss">
				        <tr><td colspan='2'>
				             <span class="problems">${ss.count}.&nbsp;${ques.problem }</span>&nbsp;
				            </td>
				        </tr>
				         <c:if test="${!empty score}">
					        <tr><td colspan='2'>
						             <c:if test="${!ques.ansright}">
						                 <img alt="" class="ansimgs" src="img/qt/cuohao.jpg">
						                 <span class="rtans">答案：  ${fn:replace(fn:replace(fn:replace(fn:replace(fn:replace(ques.ans, "|", ""), "4", "D"), "3", "C"), "1", "A"), "2", "B")}</span>
						             </c:if>
						             <c:if test="${ques.ansright}">
						                 <img alt="" class="ansimgs" src="img/qt/zhengque.jpg">
						             </c:if>
					             
					            </td>
					        </tr>
				        </c:if>
				          <c:if test="${fn:contains(ques.ans, '|')}">
				            <tr><td class="xuanxiang" colspan='2'><input type='checkbox' name='${ques.id}' value="1">&nbsp;A ${ques.op1 }</td></tr>
				            <tr><td class="xuanxiang" colspan='2'><input type='checkbox' name='${ques.id}' value="2">&nbsp;B ${ques.op2 }</td></tr>
				            <tr><td class="xuanxiang" colspan='2'><input type='checkbox' name='${ques.id}' value="3">&nbsp;C ${ques.op3 }</td></tr>
					          <c:if test="${fn:length(ques.op4)>0}">
					            <tr><td class="xuanxiang" colspan='2'><input type='checkbox' name='${ques.id}' value="4">&nbsp;D ${ques.op4 }</td></tr>
					          </c:if>
				          </c:if>
				          <c:if test="${! fn:contains(ques.ans, '|')}">
				            <tr><td class="xuanxiang" colspan='2'><input type='radio' name='${ques.id}' value="1">&nbsp;A ${ques.op1 }</td></tr>
				            <tr><td class="xuanxiang" colspan='2'><input type='radio' name='${ques.id}' value="2 ">&nbsp;B ${ques.op2 }</td></tr>
				            <tr><td class="xuanxiang" colspan='2'><input type='radio' name='${ques.id}' value="3">&nbsp;C ${ques.op3 }</td></tr>
				            <c:if test="${fn:length(ques.op4)>0}">
					            <tr><td class="xuanxiang" colspan='2'><input type='radio' name='${ques.id}' value="4">&nbsp;D ${ques.op4 }</td></tr>
					        </c:if>
				          </c:if>
					   </c:forEach>
				     </c:if>
				      <tr><td colspan="2"></td></tr>
				    <tr><td style="height:25px;" colspan="2">二、填空题（15*2分）</td></tr>
				    <c:if test="${!empty queslist.tklist}">
				       <c:forEach items="${queslist.tklist }" var="ques" varStatus="ss">
				        <tr>
				          <td colspan='2'>
				           <span class="problems">${ss.count}.&nbsp; ${ques.problem}</span>&nbsp;
				          </td>
				        </tr>
				         <c:if test="${!empty score}">
				         <tr>
				          <td colspan='2'>
					             <c:if test="${!ques.ansright}">
					                 <img alt="" class="ansimgs" src="img/qt/cuohao.jpg" />
					                 <span class="rtans">答案：  ${fn:replace(ques.ans, "|", ",")}</span>
					             </c:if>
					             <c:if test="${ques.ansright}">
					                 <img alt="" class="ansimgs" src="img/qt/zhengque.jpg">
					             </c:if>
				             
				            </td>
				          </tr>
				        </c:if>
				          <c:if test="${fn:contains(ques.ans, '|')}">
				          <tr><td class="tiankong">答案：</td><td> 
				            <c:forEach items="${fn:split(ques.ans, '|')}">
				              <input class='tkdaan' name="${ques.id }"  maxlength='100'/>
				            </c:forEach>
				           </td></tr>
				          </c:if>
				          <c:if test="${! fn:contains(ques.ans, '|')}">
				            <tr><td class="tiankong" >答案：</td><td><input class='tkdaan' name="${ques.id }" maxlength='100'/></td></tr>
				          </c:if>
					   </c:forEach>
				     </c:if>
				     <tr><td colspan="2"></td></tr>
				    <tr><td style="height:25px;" colspan="2">三、判断题（15*2分）</td></tr>
				    <c:if test="${!empty queslist.pdlist}">
				       <c:forEach items="${queslist.pdlist }" var="ques" varStatus="ss">
				        <tr>
				             <td colspan='2'>
				              <span class="problems">${ss.count}.&nbsp;${ques.problem }</span>&nbsp;
				              </td>
				        </tr>
				         <c:if test="${!empty score}">
				        <tr>
				             <td colspan='2'>
					             <c:if test="${!ques.ansright}">
					                 <img alt="" class="ansimgs" src="img/qt/cuohao.jpg">
					                 <span class="rtans">答案：  ${fn:replace(fn:replace(ques.ans, "1", "正确"), "0", "错误")}</span>
					             </c:if>
					             <c:if test="${ques.ansright}">
					                 <img alt="" class="ansimgs" src="img/qt/zhengque.jpg">
					             </c:if>
				              
				              </td>
				        </tr>
				        </c:if>
				        <tr><td class="xuanxiang" colspan='2'><input type='radio' name='${ques.id }' value="1">正确&nbsp;&nbsp;<input type='radio' name='${ques.id }' value="0">错误</td></tr>
					   </c:forEach>
				     </c:if>
				    <tr><td colspan="2"></td></tr>
			       </table>
			       <c:if test="${empty score}">
			        <img onclick="JiaoJuan()" style="border:0px;margin-bottom:20px;cursor:pointer;" src="img/qt/jiaojuan.jpg"/>
			       </c:if>
			      <c:if test="${!empty score}">
			        <a href="javascript:self.close()">
			          <img style="border:0px;margin-bottom:20px;margin-top:30px;" src="img/qt/kstc.jpg"/>
			        </a>
			       </c:if>
			    </c:if>
			     <c:if test="${empty queslist}">
			       <c:if test="${empty error}">
			                     暂无测试！
			         <br/>
			        <a href="javascript:self.close();">
			           <img style="border:0px;margin-bottom:20px;margin-top:30px;float:left;margin-left:427px;" src="img/qt/kstc.jpg"/>
			          </a>
			       </c:if>
			        <c:if test="${!empty error}">
			          ${error}
			          <br/>
			          <a href="javascript:self.close();">
			           <img style="border:0px;margin-bottom:20px;margin-top:30px;" src="img/qt/kstc.jpg"/>
			          </a>
			       </c:if>
			     </c:if>
			     
           </div>
           <div id="mainbottom"></div>
       </div>
      <div id="footht" style=""></div>
      <div id="footer">
		  <jsp:include page="footer.jsp" flush="true"></jsp:include>
	   </div>
     </div>
     <div id="mainright"><img src="img/qt/mainright.jpg" style="width:100%;height:100%;"/></div>
     <form id="jiaojuansum" name="jiaojuansum" method="post" action="nmks.do" >
       <input id="xzds" name="xzds" type="hidden" value="">
       <input id="tkds" name="tkds" type="hidden" value="">
       <input id="pdds" name="pdds" type="hidden" value="">
     </form>
  </body>
<SCRIPT LANGUAGE="JavaScript">   
		<!--   
	     //下面兼容ie6
	     var isIE = !!window.ActiveXObject;  
		 var isIE6 = isIE && !window.XMLHttpRequest; 
		 if (isIE6) {  
	      $("#timeleng").css("margin-left","200px");
	    } 
		//-->   
</SCRIPT>
</html>
